/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package combomodel;

import eloma.classe.Cliente;
import java.util.List;
import javax.swing.AbstractListModel;
import javax.swing.ComboBoxModel;

/**
 *
 * @author Icaro
 */
public class ComboBoxClienteModel extends AbstractListModel implements ComboBoxModel {

    private List<Cliente> listaCliente;
    private Cliente selection;

    public ComboBoxClienteModel(List<Cliente> listaCliente) {
        this.listaCliente = listaCliente;
    }

    @Override
    public int getSize() {
        return listaCliente.size();
    }

    @Override
    public Cliente getElementAt(int index) {
        return listaCliente.get(index);
    }

    @Override
    public void setSelectedItem(Object anItem) {
        selection = (Cliente) anItem;
    }

    @Override
    public Object getSelectedItem() {
        return selection;
    }

}
